﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Gencode.PrsWeb.App;

namespace Gencode.PrsWeb
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
			_errorPanelStandard.Visible = false;
        }

		protected void _buttonGo_Click(object sender, EventArgs e)
		{
			User ur = Gencode.PrsWeb.App.User.SetUserRights(_userName.Text, _userPassword.Text);

			if (ur != null)
			{
				Session["USERRIGHTS"] = ur;
                string defaultPage = ConfigurationManager.AppSettings.Get("DefaultPage");
                if (defaultPage != null && defaultPage != string.Empty)
                {
                    //bool error = false;
                    //try
                    //{
                        Response.Redirect(defaultPage);
                    //}
                    //catch (Exception ex)
                    //{
                    //    Session["TITLE"] = "Fehler beim Laden";
                    //    Session["MESSAGE"] = "Die Seite " + defaultPage + " konnte nicht geladen werden!";
                    //    Response.Redirect("Default.aspx");
                    //}
                }
                Response.Redirect("Default.aspx");
			}
			else
			{
				_errorPanelStandard.Visible = true;
			}
		}
    }
}
